namespace 第四次作业
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {
           OpenFileDialog ofd = new OpenFileDialog();
           ofd.Title = "请选择需要合并的第一个文件";
           ofd.InitialDirectory= System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
           ofd.Filter = "TXT|*.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                label1.Text = ofd.FileName;
            }
            else
            {
                label1.Text = "设置失败";
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "请选择需要合并的第二个文件";
            ofd.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            ofd.Filter = "TXT|*.txt";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                label2.Text = ofd.FileName;
            }
            else
            {
                label1.Text = "设置失败";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string mulu = System.Windows.Forms.Application.StartupPath + "\\Data";
                if (Directory.Exists(mulu) == false)
                {
                    Directory.CreateDirectory(mulu);
                }
                string text1 = File.ReadAllText(label1.Text);
                File.AppendAllText(mulu + "\\hebing.txt", text1, System.Text.Encoding.UTF8);
                string text2 = File.ReadAllText(label2.Text);
                File.AppendAllText(mulu + "\\hebing.txt", text2,System.Text.Encoding.UTF8);
                this.label3.Text = "OK";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            }
        private void label3_Click(object sender, EventArgs e)
        {

        }
    }
}